package com.jyh.homework.homework3;

import java.io.*;

/**
 * @Author JYH
 * @Date 2024/8/6 20:13
 * @Description 分别使用文件流和缓冲流复制一个长度大于100MB的视频文件，并观察效率的差异
 */
public class Homework3 {
    public static void main1(String[] args) throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:\\course\\02-JavaSE-plus\\day10-IO流\\录屏\\110-内存流的读和写操作.avi"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("D:\\course\\02-JavaSE-plus\\day10-IO流\\110s-内存流的读和写操作.avi"));
        byte[] bytes1 = new byte[1024 * 1024];
        int len1=-1;
        while ((len1=bis.read(bytes1))!=-1){
            bos.write(bytes1,0,len1);
            bos.flush();
        }
        bos.close();
        bis.close();
    }
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("D:\\course\\02-JavaSE-plus\\day10-IO流\\录屏\\110-内存流的读和写操作.avi");
        FileOutputStream fos = new FileOutputStream("D:\\course\\02-JavaSE-plus\\day10-IO流\\110-内存流的读和写操作.avi");
        byte[] bytes = new byte[1024*1024];
        int len=-1;
        while ((len=fis.read(bytes))!=-1){
            fos.write(bytes,0,len);
            fos.flush();
        }
        fos.close();
        fis.close();

    }
}
